/* To display input data in input.txt */

#include "data.h"

int input(data md, const char *filename)
{
	FILE *istream;
	if(( istream  = fopen( filename, "w" )) == NULL ) {
		cout<<  "The file 'data' was not opened" << endl;
		exit(1);
	}

	int i, j ;

	fprintf( istream, "%d  %d  %d\n\n", md.getnbJobs(), 
	            	md.getnbStages(), md.getnbMachinesPerStage());

	for ( i = 0; i < md.getnbJobs(); i++) {
		fprintf( istream, "%d ", i);
		
		for ( j = 0; j < md.getnbStages(); j++){
			fprintf( istream, "%d ", md.getPtimes( i, j ) );
			if ( j == md.getnbStages() - 1)
				fprintf( istream, "\n");		
		}

	}
	fprintf( istream, "\n");

	for ( i = 0; i < md.getnbStages(); i ++)
		for ( j = 0; j < md.getnbMachinesPerStage(); j ++) {
			fprintf( istream, "%d ", md.getMachines( i, j ) );
			if ( j == md.getnbMachinesPerStage() - 1) 
				fprintf( istream, "\n");
		}
	fprintf( istream, "\n\n");

   //  fprintf(istream, "%d %d %d \n", md.getMachines(4,0), md.getMachines(4,1), md.getMachines(4,2));
	
	fclose(istream);
	return 0;
}